// app.js
import './utils/utils'
import './utils/http'
App({
  globalData: {},
  userInfo: {avatar:'', name:'微信用户',number:'',phone:''},
  getToken(type = 'token'){
    // this.token=wx.getStorageSync('token')
    return wx.getStorageSync(type)
  },
  //  将token 储存本地
  setToken(key, token) {
    // 将 token 记录在应用实例中   
   this[key] = token
   // 将 token 存入本地
   wx.setStorageSync(key, token)
 },
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
  
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null
  }
})
